import MySQLdb
# make sure you install two things before running this script:
# mysql server 5.5 => http://dev.mysql.com/tech-resources/articles/mysql-installer-for-windows.html
# mysql connector for python => http://www.codegood.com/archives/129


# sample db in mysql installation
# the db sakila comes with the installation
db = MySQLdb.connect(host="localhost", user="root", passwd="123456", db="sakila")

cursor = db.cursor()
stmt = "SELECT * FROM sakila.actor"
cursor.execute(stmt)

rows = cursor.fetchall ()
for row in rows:
    print "Row: "
    for col in row :
        print "Column: %s" % (col)
    print "End of Row"
print "Number of rows returned: %d" % cursor.rowcount

cursor.close()

db.close()

